<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    #div{
        margin-left: 80px;
        border: 1px solid ;
        width: 300px;
    }
    
</style>
<body>
    <div id="div">
        <h3>添加博客</h3>
        <table>
    
            <tr>
                <td>标题</td>
                <td><input type="text" name="title"></td>
            </tr>
            <tr>
                <td>摘要</td>
                <td><input type="text" name="digest"></td>
            </tr>
            <tr>
                <td>内容</td>
                <td><input type="text" name="content"></td>
            </tr>
            <tr>
                <td>分类</td>
                <td><input type="text" name="sort"></td>
            </tr>
            <tr>
                <td>作者</td>
                <td><input type="text" name="author"></td>
            </tr>
            <tr>
                <td id="cancel"><input type="button" value="取消" onclick="cancel()"></td>
                <td id="append"><input type="button" value="添加" onclick="append()"></td>
            </tr>
        </table>
    </div>
    
    <script src="./js/jquery-3.6.0.min.js"></script>
    <script>
        $(function(){
        
            

        })

        function cancel(){
            window.location.href='./index.html'
        }
        function append(){
            console.log('添加');
            let title=$('[name=title]').val();
            let digest=$('[name=digest]').val();
            let content=$('[name=content]').val();
            let sort=$('[name=sort]').val();
            let author=$('[name=author]').val()
            
            let obj={
                title,
                digest,
                content,
                sort,
                author
            }
            $.post(`http://localhost:8888/blog`,obj,data=>{
                window.location.href='./index.html'
            })
        }

    </script>
</body>
</html>